package com.own.component.util.database.mysql;

/**
 * CreateSqlData
 *
 * @author chenxueli
 * @date 2022-10-23 16:06:00
 */
public final class CreateSqlData {

    public static final String DATA =
            "drop table if exists opm_project;\n" +
                    "create table if not exists opm_project\n" +
                    "(\n" +
                    "    id               bigint(20)                           not null comment '主键id' primary key,\n" +
                    "    name             varchar(50)                          null comment '项目名称',\n" +
                    "    group_id         bigint(20)                           null comment '项目组id',\n" +
                    "    is_disabled      tinyint(1)                           null comment '是否不可用 0=可用 1=不可用',\n" +
                    "    cover            varchar(255)                         null comment '项目封面',\n" +
                    "    path             varchar(255)                         null comment '项目路径',\n" +
                    "    description      varchar(255)                         null comment '项目描述',\n" +
                    "    memo           varchar(500)                         null comment '备注信息',\n" +
                    "    create_user_id   bigint(20)                           null comment '创建人;用户id',\n" +
                    "    create_user_name varchar(50)                          null comment '创建人用户名',\n" +
                    "    gmt_create       datetime   default current_timestamp null comment '创建时间',\n" +
                    "    update_user_id   bigint(20)                           null comment '更新人用户id',\n" +
                    "    update_user_name varchar(50)                          null comment '更新人用户名',\n" +
                    "    gmt_modified     datetime   default current_timestamp null on update current_timestamp comment '更新时间',\n" +
                    "    is_deleted       tinyint(1) default 0                 null comment '逻辑删除字段（0=存在 1=删除）',\n" +
                    "    version          int        default 0                 null comment '数据版本号'\n" +
                    ") comment '项目管理表' charset = utf8mb4;\n" +
                    "\n" +
                    "drop table if exists opm_project_user;\n" +
                    "create table if not exists opm_project_user\n" +
                    "(\n" +
                    "    id               bigint(20)                           not null comment '主键id' primary key,\n" +
                    "    fk_user_id       bigint(20)                           null comment '用户id',\n" +
                    "    fk_project_id    bigint(20)                           null comment '项目id',\n" +
                    "    permission       tinyint(1)                           null comment '权限信息 1=create 2=master 3=developer 4=guest',\n" +
                    "    memo           varchar(500)                         null comment '备注信息',\n" +
                    "    create_user_id   bigint(20)                           null comment '创建人用户id',\n" +
                    "    create_user_name varchar(50)                          null comment '创建人用户名',\n" +
                    "    gmt_create       datetime   default current_timestamp null comment '创建时间',\n" +
                    "    update_user_id   bigint(20)                           null comment '更新人用户id',\n" +
                    "    update_user_name varchar(50)                          null comment '更新人用户名',\n" +
                    "    gmt_modified     datetime   default current_timestamp null on update current_timestamp comment '更新时间',\n" +
                    "    is_deleted       tinyint(1) default 0                 null comment '逻辑删除字段（0=存在 1=删除）',\n" +
                    "    version          int        default 0                 null comment '数据版本号'\n" +
                    ") comment '项目人员管理表' charset = utf8mb4;\n" +
                    "\n" +
                    "create index idx_user on opm_project_user (fk_user_id);\n" +
                    "create index idx_project on opm_project_user (fk_project_id);\n" +
                    "create index idx_user_project on opm_project_user (fk_user_id, fk_project_id);\n" +
                    "\n" +
                    "drop table if exists opm_project_develop;\n" +
                    "create table if not exists opm_project_develop\n" +
                    "(\n" +
                    "    id                bigint(20)                           not null comment '主键id' primary key,\n" +
                    "    fk_project_id     bigint(20)                           null comment '项目id',\n" +
                    "    name              varchar(50)                          null comment '开发版名称',\n" +
                    "    is_suggest_use    tinyint(1) default 0                 null comment '是否是建议使用的版本 1=是 0=不是',\n" +
                    "    is_discard        tinyint(1) default 0                 null comment '是否废弃 1=是 0=不是',\n" +
                    "    is_disabled       tinyint(1)                           null comment '是否不可用 0=可用 1=不可用',\n" +
                    "    description       varchar(255)                         null comment '开发版描述',\n" +
                    "    database_username varchar(50)                          null comment '数据库用户名',\n" +
                    "    database_password varchar(50)                          null comment '数据库密码',\n" +
                    "    database_name     varchar(50)                          null comment '数据库名称',\n" +
                    "    database_type     tinyint(1)                           null comment '数据库类型',\n" +
                    "    database_host     varchar(50)                          null comment '数据库地址',\n" +
                    "    database_port     varchar(50)                          null comment '数据库端口',\n" +
                    "    module_names      varchar(500)                         null comment '依赖的模块名称列表',\n" +
                    "    memo            varchar(500)                         null comment '备注信息',\n" +
                    "    create_user_id    bigint(20)                           null comment '创建人用户id',\n" +
                    "    create_user_name  varchar(50)                          null comment '创建人用户名',\n" +
                    "    gmt_create        datetime   default current_timestamp null comment '创建时间',\n" +
                    "    update_user_id    bigint(20)                           null comment '更新人用户id',\n" +
                    "    update_user_name  varchar(50)                          null comment '更新人用户名',\n" +
                    "    gmt_modified      datetime   default current_timestamp null on update current_timestamp comment '更新时间',\n" +
                    "    is_deleted        tinyint(1) default 0                 null comment '逻辑删除字段（0=存在 1=删除）',\n" +
                    "    version           int        default 0                 null comment '数据版本号'\n" +
                    ") comment '项目开发表' charset = utf8mb4;\n" +
                    "\n" +
                    "create index idx_project on opm_project_develop (fk_project_id);\n" +
                    "\n" +
                    "drop table if exists opm_project_generate_history;\n" +
                    "create table if not exists opm_project_generate_history\n" +
                    "(\n" +
                    "    id               bigint(20)                           not null comment '主键id' primary key,\n" +
                    "    fk_project_id    bigint(20)                           null comment '项目id',\n" +
                    "    fk_template_id   bigint(20)                           null comment '使用的模板id',\n" +
                    "    fk_develop_id    bigint(20)                           null comment '项目开发id',\n" +
                    "    file_count       int        default 0                 null comment '文件数量',\n" +
                    "    fk_file_id       bigint(20)                           null comment '文件包id',\n" +
                    "    memo           varchar(500)                         null comment '备注信息',\n" +
                    "    create_user_id   bigint(20)                           null comment '创建人用户id',\n" +
                    "    create_user_name varchar(50)                          null comment '创建人用户名',\n" +
                    "    gmt_create       datetime   default current_timestamp null comment '创建时间',\n" +
                    "    update_user_id   bigint(20)                           null comment '更新人用户id',\n" +
                    "    update_user_name varchar(50)                          null comment '更新人用户名',\n" +
                    "    gmt_modified     datetime   default current_timestamp null on update current_timestamp comment '更新时间',\n" +
                    "    is_deleted       tinyint(1) default 0                 null comment '逻辑删除字段（0=存在 1=删除）',\n" +
                    "    version          int        default 0                 null comment '数据版本号'\n" +
                    ") comment '项目代码生成流水表' charset = utf8mb4;\n" +
                    "\n" +
                    "create index idx_project on opm_project_generate_history (fk_project_id);\n" +
                    "create index idx_template on opm_project_generate_history (fk_template_id);\n" +
                    "create index idx_develop on opm_project_generate_history (fk_develop_id);\n" +
                    "create index idx_file on opm_project_generate_history (fk_file_id);";

}
